package com.vains.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.vains.entity.OauthClientDetails;
import com.vains.mapper.OauthClientDetailsMapper;
import com.vains.service.IOauthClientDetailsService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author vains
 * @since 2020-08-11
 */
@Service
public class OauthClientDetailsServiceImpl extends ServiceImpl<OauthClientDetailsMapper, OauthClientDetails> implements IOauthClientDetailsService {

    @Override
    public List<OauthClientDetails> getByClient(String clientId, String clientSecret) {
        QueryWrapper<OauthClientDetails> wrapper = new QueryWrapper<>();
        wrapper.eq("client_id", clientId);
        wrapper.eq("client_secret", clientSecret);
        return baseMapper.selectList(wrapper);
    }

    @Override
    public OauthClientDetails getByClientId(String clientId) {
        QueryWrapper<OauthClientDetails> wrapper = new QueryWrapper<>();
        wrapper.eq("client_id", clientId);
        return baseMapper.selectOne(wrapper);
    }
}
